Page({
  data: {
    statusBarHeight: 0,
    version: 'V1.0'
  },

  onLoad() {
    const windowInfo = wx.getWindowInfo();
    this.setData({
      statusBarHeight: windowInfo.statusBarHeight
    });
  },

  onShow() {
    // 🔔 自动初始化通知组件
    const app = getApp();
    app.autoInitNotification();
  },

  // 返回
  goBack() {
    wx.navigateBack();
  },

  // 用户手册
  goToManual() {
    wx.navigateTo({
      url: '/pages/agreement/index?type=manual'
    });
  },

  // 隐私政策
  goToPrivacy() {
    wx.navigateTo({
      url: '/pages/agreement/index?type=privacy'
    });
  },

  // 检查更新
  checkUpdate() {
    wx.showLoading({
      title: '检查中...',
      mask: true
    });

    setTimeout(() => {
      wx.hideLoading();
      wx.showToast({
        title: '已是最新版本',
        icon: 'success'
      });
    }, 1500);
  },

  // 清空缓存
  clearCache() {
    wx.showModal({
      title: '提示',
      content: '确定要清空缓存吗？',
      success: (res) => {
        if (res.confirm) {
          wx.showLoading({
            title: '清理中...',
            mask: true
          });

          setTimeout(() => {
            wx.hideLoading();
            wx.showToast({
              title: '清理成功',
              icon: 'success'
            });
          }, 1000);
        }
      }
    });
  },

  // 举报信息
  goToReport() {
    wx.navigateTo({
      url: '/pages/reports/index'
    });
  }
});

